package com.zhkj.crawl.config.okhttp;

import okhttp3.*;

import java.io.IOException;

public class NetInterceptor implements Interceptor {

    public NetInterceptor() {
        super();
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        String path = request.url().uri().getPath();
        if(path.contains("follower/list")){
            //移除头部参数
            request = request.newBuilder()
//                .removeHeader("User-Agent")
//                .removeHeader("accept-encoding")
//                .header("accept-encoding", "gzip, deflate, br")
                    .build();
        }
        return chain.proceed(request);
//        Response response = chain.proceed(request);
//        if (response.body() != null && response.body().contentType() != null) {
//            MediaType mediaType = response.body().contentType();
//            String content = response.body().string();
//            ResponseBody responseBody = ResponseBody.create(mediaType, content);
//            return response.newBuilder().body(responseBody).build();
//        } else {
//            return response;
//        }
    }

}
